package com.itlong.cloud.propertyapp.resource;

import com.itlong.cloud.POJO.DTO.app.property.app.PropertyAppInspectDTO;
import com.itlong.cloud.POJO.VO.app.property.app.PropertyAppMessageVO;
import com.itlong.cloud.propertyapp.service.IPropertyAppMessageService;
import com.itlong.cloud.user.propertyapp.IPropertyAppMessageServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      物业APP消息管理模块服务接口暴露实现类
 * </desc>
 *
 * @createDate2020/1/3
 **/
@RestController
public class PropertyAppMessageServiceResource implements IPropertyAppMessageServiceClient {

    @Autowired
    private IPropertyAppMessageService iPropertyAppMessageService;

    /**
     * <desc>
     *      保存公告/内部通知信息
     * </desc>
     *
     * @param projectId 项目id
     * @param title  标题
     * @param postMan 发布人
     * @param content 发布内容
     * @return
     * @Author Zhu.yj
     * @createDate  2020/1/3
     */
    @Override
    @PostMapping("/home/postNotice")
    public Integer postNotice(@RequestParam("projectId") String projectId,
                              @RequestParam("title") String title,
                              @RequestParam("postMan") String postMan,
                              @RequestParam("content") String content,
                              @RequestParam("userId") String userId) throws Exception {
        return iPropertyAppMessageService.postNotice(projectId,title,postMan,content,userId);
    }

    /**
     * <desc>
     *      获取公告列表
     * </desc>
     *
     * @param projectId 项目id
     * @param pageNum 页码
     * @return
     * @Author Zhu.yj
     * @createDate  2020/1/3
     */
    @Override
    @PostMapping("/home/getNoticeList")
    public Map<String, Object> getNoticeList(@RequestParam("projectId") String projectId,
                                             @RequestParam("pageNum") String pageNum,
                                             @RequestParam("userId") String userId) throws Exception {
        return iPropertyAppMessageService.getNoticeList(projectId,pageNum,userId);
    }

    /**
     * <desc>
     *      获取公告详情，并记录消息是否已读
     * </desc>
     *
     * @param projectId
     * @param noticeId
     * @param userId
     * @return
     * @Author Zhu.yj
     * @createDate  2020/1/3
     */
    @Override
    @PostMapping("/home/getNoticeDetail")
    public Map<String, Object> getNoticeDetail(@RequestParam("projectId") String projectId,
                                               @RequestParam("noticeId") String noticeId,
                                               @RequestParam("userId") String userId) throws Exception {
        return iPropertyAppMessageService.getNoticeDetail(projectId,noticeId,userId);
    }

    /**
     * <desc>
     *      获取消息中心列表
     * </desc>
     *
     * @return 消息中心列表
     * @author wangzhi
     * @createDate 2020/02/17
     */
    @Override
    @PostMapping("/home/getMessagesList")
    public Map<String, Object> getMessagesList(@RequestBody PropertyAppInspectDTO propertyAppInspectDTO) throws Exception {
        return iPropertyAppMessageService.getMessagesList(propertyAppInspectDTO);
    }

    /**
     * <desc>
     *      获取公告消息内容列表
     * </desc>
     *
     * @param projectId 项目id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/13
     */
    @PostMapping("/home/getNoticeContent")
    public List<String> getNoticeContent(@RequestParam("projectId") String projectId) throws Exception{
        return iPropertyAppMessageService.getNoticeContent(projectId);
    }
}
